using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using Fan.Dongping.DataBase;

namespace Fan.Dongping.DataAccess
{
    public class PermissionDA
    {
        public static bool HaveWorkflowPermission(string userNo, string workflowNo)
        {
            string sql = "select yn_exe from jkkb131_flw_usraut p where p.flw_no =@workflowNo and p.userno=@userNo";
            SqlParameter[] paras = new SqlParameter[2];
            paras[0] = new SqlParameter("@workflowNo", workflowNo);
            paras[1] = new SqlParameter("@userNo", userNo);

            object o = DA_Base.ExecuteScalar(sql, paras);

            if ((o is DBNull) || (o == null))
            {
                return false;
            }
            else
            {
                string s = o as string;
                if (s.ToLower() == "y")
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
        }

        public static bool HaveItemPermission(string userNo, string workflowNo, string itemNo)
        {
            string sql = "select yn_exe from jkkb132_item_usraut p where p.flw_no =@workflowNo and p.userno=@userNo and p.item_no=@itemNo";
            SqlParameter[] paras = new SqlParameter[3];
            paras[0] = new SqlParameter("@workflowNo", workflowNo);
            paras[1] = new SqlParameter("@userNo", userNo);
            paras[2] = new SqlParameter("@itemNo", itemNo);

            object o = DA_Base.ExecuteScalar(sql, paras);

            if ((o is DBNull) || (o == null))
            {
                return false;
            }
            else
            {
                string s = o as string;
                if (s.ToLower() == "y")
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
        }

    }
}
